/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#ifndef MK_STATE_GRID_B_DATA_TYPE_H
#define MK_STATE_GRID_B_DATA_TYPE_H
#include "MkSip/MkSipServer.h"

typedef enum _state_grid_b_message_type
{
    MkStateGridBRegister,
    MkStateGridBResoursePush,
    MkStateGridBGetResourse,
    MkStateGridBGetAlarm,
    MkStateGridBGetRecord,
    MkStateGridBMedia,
    MkStateGridBSubscribe,
    MkStateGridBSubscribeNotify,
    MkStateGridBMediaShutDown,
    MkStateGridBPtzControl,
}MkStateGridBMessageType;

typedef enum _state_grid_b_subscribe_type
{
    MkStateGridBSubscribeAlarm,
    MkStateGridBSubscribeStatus,
    MkStateGridBSubscribeEnd
}MkStateGridBSubscribeType;

typedef enum _state_grid_b_alarm_type
{
    MkStateGridBAlarmVideoLost = 1 << 0,
    MkStateGridBAlarmMotionDetection = 1 << 1,
    MkStateGridBAlarmVideoOcclusion = 1 << 2,
    MkStateGridBAlarmDeviceHighTemperature = 1 << 8,
    MkStateGridBAlarmDeviceLowTemperature = 1 << 9,
    MkStateGridBAlarmFanFailure = 1 << 10,
    MkStateGridBAlarmDiskFailure = 1 << 11,
    MkStateGridBAlarmStateEvent = 1 << 16,
    MkStateGridBAlarmAll = 0xFFFFFFFF
}MkStateGridBAlarmType;

typedef enum _state_grid_b_record_type
{
    MkStateGridBRecordVideoLost = 1 << 0,
    MkStateGridBRecordMotionDetection = 1 << 1,
    MkStateGridBRecordVideoOcclusion = 1 << 2,
    MkStateGridBRecordDeviceHighTemperature = 1 << 8,
    MkStateGridBRecordDeviceLowTemperature = 1 << 9,
    MkStateGridBRecordFanFailure = 1 << 10,
    MkStateGridBRecordDiskFailure = 1 << 11,
    MkStateGridBRecordStateEvent = 1 << 16,
    MkStateGridBRecordAlarm = MkStateGridBRecordVideoLost | MkStateGridBRecordMotionDetection | MkStateGridBRecordVideoOcclusion | MkStateGridBRecordDeviceHighTemperature | MkStateGridBRecordDeviceLowTemperature | MkStateGridBRecordFanFailure | MkStateGridBRecordDiskFailure | MkStateGridBRecordStateEvent,
    MkStateGridBRecordTime = 1 << 20,
    MkStateGridBRecordManual = 1 << 21,
    MkStateGridBRecordAll = 0xFFFFFFFF
}MkStateGridBRecordType;

//typedef enum _state_grid_b_ptz_command_type
//{
//    MkStateGridBPtzApertuerCloseStop = 0x0101,
//    MkStateGridBPtzApertuerClose = 0x0102,
//    MkStateGridBPtzApertuerOpen = 0x0103,
//    MkStateGridBPtzApertuerOpenStop = 0x0104,
//    MkStateGridBPtzFocusNearStop = 0x0201,
//    MkStateGridBPtzFocusNear = 0x0202,
//    MkStateGridBPtzFocusFarStop = 0x0203,
//    MkStateGridBPtzFocusFar = 0x0204,
//    MkStateGridBPtzZoomInStop = 0x0301,
//    MkStateGridBPtzZoomIn = 0x0302,
//    MkStateGridBPtzZoomOutStop = 0x0303,
//    MkStateGridBPtzZoomOut = 0x0304,
//    MkStateGridBPtzUpStop = 0x0401,
//    MkStateGridBPtzUp = 0x0402,
//    MkStateGridBPtzDownStop = 0x0403,
//    MkStateGridBPtzDown = 0x0404,
//    MkStateGridBPtzRightStop = 0x0501,
//    MkStateGridBPtzRight = 0x0502,
//    MkStateGridBPtzLeftStop = 0x0503,
//    MkStateGridBPtzLeft = 0x0504,
//    MkStateGridBPtzSetPreset = 0x0601,
//    MkStateGridBPtzCallPreset = 0x0602,
//    MkStateGridBPtzDelPreset = 0x0603,
//    MkStateGridBPtzLeftUpStop = 0x0701,
//    MkStateGridBPtzLeftUp = 0x0702,
//    MkStateGridBPtzLeftDownStop = 0x0703,
//    MkStateGridBPtzLeftDown = 0x0704,
//    MkStateGridBPtzRightUpStop = 0x0801,
//    MkStateGridBPtzRightUp = 0x0802,
//    MkStateGridBPtzRightDownStop = 0x0803,
//    MkStateGridBPtzRightDown = 0x0804,
//    MkStateGridBPtzStop = 0x0901,
//    MkStateGridBPtzWiperOn = 0x0a01,
//    MkStateGridBPtzWiperOff = 0x0a02,
//    MkStateGridBPtzLightOn = 0x0b01,
//    MkStateGridBPtzLightOff = 0x0b02,
//    MkStateGridBPtzWarmOn = 0x0c01,
//    MkStateGridBPtzWarmOff = 0x0c02,
//    MkStateGridBPtzInfraredOn = 0x0d01,
//    MkStateGridBPtzInfraredOff = 0x0d02,
//    MkStateGridBPtzLinearSweep = 0x0e01,
//    MkStateGridBPtzLinearSweepStop = 0x0e02,
//    MkStateGridBPtzTrajectoryCruise = 0x0f01,
//    MkStateGridBPtzTrajectoryCruiseStop = 0x0f02,
//    MkStateGridBPtzPresetCruise = 0x1001,
//    MkStateGridBPtzPresetCruiseOff = 0x1002,
//    MkStateGridBPtzLock = 0x1101,
//    MkStateGridBPtzUnLock = 0x1102,
//    MkStateGridBPtzSetDefaultPreset = 0x1201
//}MkStateGridBPtzCommandType;

typedef struct _state_grid_b_resourse_item
{
    MkString            Code;
    BOOL                Status;
    MkString            Name;
    Uint32              DecodeTag;
    float               Longitude;
    float               Latitude;
    Uint32              SubNum;
}MkStateGridBResourseItem;
typedef MkMap<MkString, MkStateGridBResourseItem>  MkMapStateGridBResourse;

typedef struct _state_grid_b_alarm_item
{
    MkString            Code;
    CMkTime             BeginTime;
    Uint32              Status;
    Uint32              AlarmType;
}MkStateGridBAlarmItem;
typedef MkVector<MkStateGridBAlarmItem> MkVectorStateGridBAlarm;

typedef struct _state_grid_b_record_item
{
    MkString            FileName;
    MkString            RtspUrl;
    CMkTime             BeginTime;
    CMkTime             EndTime;
    Uint32              FileSize;
    Uint32              DecoderTag;
    Uint32              RecordType;
}MkStateGridBRecordItem;
typedef MkVector<MkStateGridBRecordItem> MkVectorStateGridBRecord;

class MkApi CMkStateGridBRequestBase
{
public:
    CMkStateGridBRequestBase(const MkString& RouterId, const MkString& DstId, const MkStateGridBMessageType& MsgType);
    virtual ~CMkStateGridBRequestBase() {};

    const MkStateGridBMessageType& GetMsgType() const { return m_MsgType; }
    const MkString& GetRouterId() const { return m_RouterId; }
    const MkString& GetDstId() const { return m_DstId; }
protected:
private:
    MkStateGridBMessageType     m_MsgType;
    MkString                    m_RouterId;
    MkString                    m_DstId;
};

class MkApi CMkStateGridBRegisterRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBRegisterRequest(const MkString &RouterId, const MkString& DstId, const MkString &DevHost, Uint16 DevPort, const MkString &AuthorType,
        const MkString &UserName, const MkString &Realm, const MkString &Nonce, const MkString &Uri, const MkString &Response, const MkString &Algorithm, Uint32 Expires);
    ~CMkStateGridBRegisterRequest() {}

    const MkString &GetAuthorType() const { return m_AuthorType; }
    const MkString &GetUserName() const { return m_UserName; }
    const MkString &GetRealm() const { return m_Realm; }
    const MkString &GetNonce() const { return m_Nonce; }
    const MkString &GetUri() const { return m_Uri; }
    const MkString &GetResponse() const { return m_Response; }
    const MkString &GetAlgorithm() const { return m_Algorithm; }
    const MkString& GetDevHost() const { return m_DevHost; }
    const Uint16& GetDevPort() const { return m_DevPort; }
    const Uint32& GetExpires() const { return m_Expires; }
protected:
private:
    MkString        m_DevHost;
    Uint16          m_DevPort;
    MkString        m_AuthorType;
    MkString        m_UserName;
    MkString        m_Realm;
    MkString        m_Nonce;
    MkString        m_Uri;
    MkString        m_Response;
    MkString        m_Algorithm;
    Uint32          m_Expires;
};

class MkApi CMkStateGridBResoursePushRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBResoursePushRequest(const MkString& RouterId, const MkString& DstId, const MkString& ParentId, const MkMapStateGridBResourse& MapResourse);
    ~CMkStateGridBResoursePushRequest() {};

    const MkMapStateGridBResourse& GetMapResourse() const { return m_MapResourse; }
    const MkString& ParentId() const { return m_ParentId; }
protected:
private:
    MkString                    m_ParentId;
    MkMapStateGridBResourse     m_MapResourse;
};

class MkApi CMkStateGridBGetResourseRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBGetResourseRequest(const MkString& RouterId, const MkString& DstId, Uint32 FromIndex, Uint32 ToIndex);
    ~CMkStateGridBGetResourseRequest() {}

    const Uint32& GetFromIndex() const { return m_FromIndex; }
    const Uint32& GetToInex() const { return m_ToIndex; }
protected:
private:
    Uint32 m_FromIndex;
    Uint32 m_ToIndex;
};

class MkApi CMkStateGridBFindRecordRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBFindRecordRequest(const MkString& RouterId, const MkString& DstId, Uint32 RecordType, const MkString& UserCode, const CMkTime& BeginTime, const CMkTime& EndTime, Uint32 FromIndex, Uint32 ToIndex);
    ~CMkStateGridBFindRecordRequest() {}

    const Uint32& GetFromIndex() const { return m_FromIndex; }
    const Uint32& GetToInex() const { return m_ToIndex; }
    const Uint32& GetRecordType() const { return m_RecordType; }
    const CMkTime& GetBeginTime() const { return m_BeginTime; }
    const CMkTime& GetEndTime() const { return m_EndTime; }
protected:
private:
    Uint32 m_FromIndex;
    Uint32 m_ToIndex;
    Uint32 m_RecordType;
    MkString m_UserCode;
    CMkTime m_BeginTime;
    CMkTime m_EndTime;
};

class MkApi CMkStateGridBGetAlarmRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBGetAlarmRequest(const MkString& RouterId, const MkString& DstId, Uint32 AlarmType, const MkString& UserCode, const CMkTime& BeginTime, const CMkTime& EndTime, Uint32 AlarmLevel, Uint32 FromIndex, Uint32 ToIndex);
    ~CMkStateGridBGetAlarmRequest() {}

    const Uint32& GetFromIndex() const { return m_FromIndex; }
    const Uint32& GetToInex() const { return m_ToIndex; }
    const Uint32& GetAlarmType() const { return m_AlarmType; }
    const Uint32& GetAlarmLevel() const { return m_AlarmLevel; }
    const CMkTime& GetBeginTime() const { return m_BeginTime; }
    const CMkTime& GetEndTime() const { return m_EndTime; }
protected:
private:
    Uint32 m_FromIndex;
    Uint32 m_ToIndex;
    Uint32 m_AlarmType;
    Uint32 m_AlarmLevel;
    MkString m_UserCode;
    CMkTime m_BeginTime;
    CMkTime m_EndTime;
};

class MkApi CMkStateGridBMediaRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBMediaRequest(const MkString& RouterId, const MkString& DstId, const MkString& SessionId, const MkString& RtpHost, Uint16 RtpAudioPort, Uint16 RtpVideoPort);
    ~CMkStateGridBMediaRequest() {};
    const MkString& GetRtpHost() const { return m_RtpHost; }
    const Uint16& GetRtpVideoPort() const { return m_RtpVideoPort; }
    const Uint16& GetRtpAudioPort() const { return m_RtpAuidoPort; }
    const MkString& GetSessionId() const { return m_SessionId; }

protected:
private:
    MkString    m_SessionId;
    MkString    m_ChannelId;
    MkString    m_RtpHost;
    Uint16      m_RtpAuidoPort;
    Uint16      m_RtpVideoPort;
};

class MkApi CMkStateGridBMediaShutDownRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBMediaShutDownRequest(const MkString& RouterId, const MkString& DstId, const MkString& SessionId);
    ~CMkStateGridBMediaShutDownRequest() {};
protected:
private:
    MkString    m_SessionId;
};

class MkApi CMkStateGridBPtzControlRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBPtzControlRequest(const MkString& RouterId, const MkString& DstId, Uint32 Cmd, Uint32 Param1, Uint32 Param2, Uint32 Param3);
    ~CMkStateGridBPtzControlRequest() {};

    const Uint32& GetCmd() const { return m_Cmd; }
    const Uint32& GetParam1() const { return m_Param1; }
    const Uint32& GetParam2() const { return m_Param2; }
    const Uint32& GetParam3() const { return m_Param3; }
    const MkString& GetChannelId() const { return m_ChannelId; }
protected:
private:
    MkString m_ChannelId;
    Uint32 m_Cmd;
    Uint32 m_Param1;
    Uint32 m_Param2;
    Uint32 m_Param3;
};

class MkApi CMkStateGridBSubscribeRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBSubscribeRequest(const MkString& RouterId, const MkString& DstId, const MkString& SubscribeId, const MkStateGridBSubscribeType& SubScribeType, Uint32 Expires, const MkMap<MkString, Uint32>& MapSubId);
    ~CMkStateGridBSubscribeRequest() {};

    const MkStateGridBSubscribeType& GetSubscribeType() const { return m_SubscribeType; }
    const Uint32& GetExpries() const { return m_Expires; }
    const MkMap<MkString, Uint32>& GetMapSubId() const { return m_MapSubCode; }
    const MkString& GetSubscribeId() const { return m_SubscribeId; }
protected:
private:
    MkStateGridBSubscribeType   m_SubscribeType;
    Uint32                      m_Expires;
    MkMap<MkString, Uint32>     m_MapSubCode;
    MkString                    m_SubscribeId;
};

class MkApi CMkStateGridBSubscribeNotifyRequest : public CMkStateGridBRequestBase
{
public:
    CMkStateGridBSubscribeNotifyRequest(const MkString& RouterId, const MkString& DstId, const MkString& SubscribeId, const MkString& StrState, const MkStateGridBSubscribeType SubscribeType, const MkString& Code, const MkString& Name, const Uint32 AlarmType, const CMkTime& StartTime, const CMkTime& EndTime, Uint32 Status);
    ~CMkStateGridBSubscribeNotifyRequest() {};

    const MkStateGridBSubscribeType& GetSubscribeType()const { return m_SubscribeType; }
    const MkString& GetSubscribeId() const { return m_SubscribeId; }
    const MkString& GetState() const { return m_StrState; }
    const MkString& GetCode() const { return m_Code; }
    const MkString& GetName() const { return m_Name; }
    const Uint32& GetAlarmType() const { return m_AlarmType; }
    const CMkTime& GetStartTime() const { return m_StartTime; }
    const CMkTime& GetEndTime() const { return m_EndTime; }
protected:
private:
    MkStateGridBSubscribeType   m_SubscribeType;
    MkString                    m_SubscribeId;
    MkString                    m_StrState;
    MkString                    m_Code;

    //alarm notify used
    MkString                    m_Name;
    Uint32                      m_AlarmType;
    CMkTime                     m_StartTime;
    CMkTime                     m_EndTime;

    //status notify used
    Uint32                      m_Status;
};

class MkApi CMkStateGridBResponseBase
{
public:
    CMkStateGridBResponseBase(const MkString& RouterId, const MkString& DstId, const MkStateGridBMessageType& MsgType);
    virtual ~CMkStateGridBResponseBase() {};

    const MkStateGridBMessageType& GetMsgType() const { return m_MsgType; }
    const MkString& GetRouterId() const { return m_RouterId; }
    const MkString& GetDstId() const { return m_DstId; }
protected:
private:
    MkStateGridBMessageType     m_MsgType;
    MkString                    m_RouterId;
    MkString                    m_DstId;
};

class MkApi CMkStateGridBGetResourceResponse : public CMkStateGridBResponseBase
{
public:
    CMkStateGridBGetResourceResponse(const MkString& RouterId, const MkString& DstId, const MkString& ParentId, Uint32 RealNum, Uint32 SubNum, Uint32 FromIndex, Uint32 ToIndex, const MkMapStateGridBResourse& MapResourse);
    ~CMkStateGridBGetResourceResponse() {};

    const Uint32& GetRealNum() const { return m_RealNum; }
    const Uint32& GetSubNum() const { return m_SubNum; }
    const Uint32& GetFromIndex() const { return m_FromIndex; }
    const Uint32& GetToIndex() const { return m_ToIndex; }
    const MkString& GetParentId() const { return m_ParentId; }
    const MkMapStateGridBResourse& GetMapResource() const { return m_MapResourse; }
protected:
private:
    MkString                    m_ParentId;
    Uint32                      m_RealNum;
    Uint32                      m_SubNum;
    Uint32                      m_FromIndex;
    Uint32                      m_ToIndex;
    MkMapStateGridBResourse     m_MapResourse;
};

class MkApi CMkStateGridBGetAlarmResponse : public CMkStateGridBResponseBase
{
public:
    CMkStateGridBGetAlarmResponse(const MkString& RouteId, const MkString& DstId, Uint32 RealNum, Uint32 SubNum, Uint32 FromIndex, Uint32 ToIndex, const MkVectorStateGridBAlarm& VecAlarm);
    ~CMkStateGridBGetAlarmResponse() {};

    const Uint32& GetRealNum() const { return m_RealNum; }
    const Uint32& GetSubNum() const { return m_SubNum; }
    const Uint32& GetFromIndex() const { return m_FromIndex; }
    const Uint32& GetToIndex() const { return m_ToIndex; }
    const MkVectorStateGridBAlarm& GetVecAlarm() const { return m_VecAlarm; }
protected:
private:
    Uint32                      m_RealNum;
    Uint32                      m_SubNum;
    Uint32                      m_FromIndex;
    Uint32                      m_ToIndex;
    MkVectorStateGridBAlarm     m_VecAlarm;
};

class MkApi CMkStateGridBGetRecordResponse : public CMkStateGridBResponseBase
{
public:
    CMkStateGridBGetRecordResponse(const MkString& RouteId, const MkString& DstId, Uint32 RealNum, Uint32 SubNum, Uint32 FromIndex, Uint32 ToIndex, const MkVectorStateGridBRecord& VecRecord);
    ~CMkStateGridBGetRecordResponse() {};

    const Uint32& GetRealNum() const { return m_RealNum; }
    const Uint32& GetSubNum() const { return m_SubNum; }
    const Uint32& GetFromIndex() const { return m_FromIndex; }
    const Uint32& GetToIndex() const { return m_ToIndex; }
    const MkVectorStateGridBRecord& GetVecRecord() const { return m_VecRecord; }
protected:
private:
    Uint32                      m_RealNum;
    Uint32                      m_SubNum;
    Uint32                      m_FromIndex;
    Uint32                      m_ToIndex;
    MkVectorStateGridBRecord    m_VecRecord;
};

class MkApi CMkStateGridBMediaResponse : public CMkStateGridBResponseBase
{
public:
    CMkStateGridBMediaResponse(const MkString& RouterId, const MkString& DstId, const MkString& SessionId, const MkString& AnswerSdp, const EventResponseCallback& EventCb);
    ~CMkStateGridBMediaResponse() {};

    const MkString& GetSessionId() const { return m_SessionId; }
    const MkString& GetAnswerSdp() const { return m_AnswerSdp; }
    const EventResponseCallback& GetEventCb() const { return m_EventCb; }
protected:
private:
    MkString    m_SessionId;
    MkString    m_AnswerSdp;
    EventResponseCallback  m_EventCb;
};

class MkApi CMkStateGridBSubscribeResponse : public CMkStateGridBResponseBase
{
public:
    CMkStateGridBSubscribeResponse(const MkString& RouterId, const MkString& DstId, const MkString& SubscribeId, Uint32 Expires);
    ~CMkStateGridBSubscribeResponse() {};

    const MkString& GetSubscribeId()const { return m_SubscribeId; }
    const Uint32& GetExpires() const { return m_Expires; }

protected:
private:
    MkString    m_SubscribeId;
    Uint32      m_Expires;
};

class MkApi CMkStateGridBRegisterResponse : public CMkStateGridBResponseBase
{
public:
    CMkStateGridBRegisterResponse(const MkString& RouterId, const MkString& DstId, const MkString& RegisterId, const MkSipStatus& SipStatus, const MkString& UpRealm, const MkString& UpNonce, const MkString Algorithm);
    ~CMkStateGridBRegisterResponse() {};
    const MkSipStatus& GetStatusCode() const { return m_Status; }
    const MkString& GetUpRealm() const { return m_UpRealm; }
    const MkString& GetUpNonce() const { return m_UpNonce; }
    const MkString& GetUpAlgorithm() const { return m_UpAlgorithm; }
    const MkString& GetRegisterId() const { return m_RegisterId; }
protected:
private:
    MkSipStatus     m_Status;
    MkString        m_UpRealm;
    MkString        m_UpNonce;
    MkString        m_UpAlgorithm;
    MkString        m_RegisterId;
};

#endif